//
//  CSMyView.m
//  Studio
//
//  Created by zhiqiang chen on 2018/9/19.
//  Copyright © 2018年 zongquankeji. All rights reserved.
//

#import "CSMyView.h"

@implementation CSMyView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        
        
        
        [self setBgImage:@"person_bg"];
        
        /**
         背景图片
         */
        UIImageView *bgImageView = [[UIImageView alloc] init];
        bgImageView.contentMode = UIViewContentModeScaleAspectFill;
        bgImageView.layer.masksToBounds = YES;
        [self addSubview:bgImageView];
//        self.bgImageView.image = [UIImage imageNamed:@"未登录头像新"];
        self.bgImageView = bgImageView;
        
        UIBlurEffect *effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
        UIVisualEffectView *effectView = [[UIVisualEffectView alloc] initWithEffect:effect];
        effectView.alpha = 0;
        [self addSubview:effectView];
        self.effectView = effectView;
        
        /**
         头像
         */
        
        UIView *bigView = [[UIView alloc]init];
        bigView.backgroundColor = CSWhiteColor3;
        bigView.layer.cornerRadius = 40;
        bigView.layer.masksToBounds = YES;
        [self addSubview:bigView];
        self.bigView = bigView;
        
        UIView *headView = [[UIView alloc]init];
        headView.backgroundColor = [CSWhiteColor colorWithAlphaComponent:0.5];
        headView.layer.cornerRadius = 37;
        headView.layer.masksToBounds = YES;
        [self addSubview:headView];
        self.headView = headView;
        
        UIButton *headBtn = [[UIButton alloc] init];
        [headBtn setImage:[UIImage imageNamed:@"未登录头像新"] forState:UIControlStateNormal];
        headBtn.clipsToBounds = YES;
        headBtn.imageView.contentMode = UIViewContentModeScaleAspectFill;
        headBtn.layer.cornerRadius = 35;
        headBtn.layer.masksToBounds = YES;
        [self.headView addSubview:headBtn];
        self.headBtn = headBtn;
        
        /**
         下一步
         */
        UIButton *arrowBtn = [[UIButton alloc] init];
        [arrowBtn setImage:@"icon_arrow1"];
        [self addSubview:arrowBtn];
        arrowBtn.titleLabel.font = SmallFont;
        self.arrowBtn = arrowBtn;
        
        /**
         昵称手机号
         */
        UILabel *telLable = [UILabel new];
        telLable.text = @"未登录";
        telLable.textColor = CSWhiteColor;
        telLable.textAlignment = NSTextAlignmentCenter;
        telLable.font = [UIFont boldSystemFontOfSize:15];
        [self addSubview:telLable];
        self.telLable = telLable;
        
        /**
         memo
         */
        UILabel *memoLable = [UILabel new];
        memoLable.text = @"折一城终老，遇一人白首";
        memoLable.numberOfLines = 0;
        memoLable.textColor = CSWhiteColor;
        memoLable.textAlignment = NSTextAlignmentCenter;
        memoLable.font = MidBigFont;
        [self addSubview:memoLable];
        self.memoLable = memoLable;
        
        /**
         圆角View
         */
        UIView *toolView = [[UIView alloc]init];
        toolView.backgroundColor = CSWhiteColor;
        [self addSubview:toolView];
        self.toolView = toolView;
        
        [self setConstraints];
        
    }
    return self;
}

-(void)setConstraints
{
    
    /**
     背景图片
     */
    [self.bgImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.edges.mas_equalTo(self);
    }];
    
    [self.effectView mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.edges.mas_equalTo(self);
    }];
    
    /**
     头像
     */
    [self.bigView mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.mas_equalTo(self);
        make.centerY.mas_equalTo(self).offset(AdaptStatusBar-20);
        make.width.height.mas_equalTo(80);
        
    }];
    
    [self.headView mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.center.mas_equalTo(self.bigView);
        
        
        make.width.height.mas_equalTo(74);
        
    }];
    
    [self.headBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        
        make.center.mas_equalTo(self.headView);
        
        make.width.height.mas_equalTo(70);
        
    }];
    
    /**
     下一步
     */
    [self.arrowBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.right.mas_equalTo(self).offset(-10);
        
        make.centerY.mas_equalTo(self);
        
        
    }];
    
    /**
     昵称
     */
    [self.telLable mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.bigView.mas_bottom).offset(20);
        
        make.centerX.mas_equalTo(self);
        
        
    }];
    
    
    
    
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    
    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.toolView.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(30, 30)];
    CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
    maskLayer.frame = self.toolView.bounds;
    maskLayer.path = maskPath.CGPath;
    self.toolView.layer.mask = maskLayer;
    
//    self.toolViewGradientLayer.frame = self.bounds;
    
}


@end

@implementation CZQSetTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.backgroundColor = CSWhiteColor;
        
        /**
         图标
         */
        UIImageView *imgView = [[UIImageView alloc]init];
        imgView.contentMode = UIViewContentModeScaleAspectFill;
        imgView.image = PlaceHold;
        [self addSubview:imgView];
        self.imgView = imgView;
        
        
        /**
         主题
         */
        UILabel *titleLable = [UILabel new];
        titleLable.text = @"动态封面";
        titleLable.textColor = CSBlackColor1;
        titleLable.font = MidBigFont;
        [self addSubview:titleLable];
        self.titleLable = titleLable;
        
        
        /**
         副主题
         */
        UILabel *subTitleLable = [UILabel new];
        subTitleLable.text = @"未绑定";
        subTitleLable.textColor = CSBlackColor1;
        subTitleLable.hidden = YES;
        subTitleLable.font = SmallFont;
        [self addSubview:subTitleLable];
        self.subTitleLable = subTitleLable;
        
        
        /**
         箭头
         */
        UIButton *arrowBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [arrowBtn setImage:@"icon_arrow2"];
        //        arrowBtn.backgroundColor =CSRedColor;
        [self addSubview:arrowBtn];
        self.arrowBtn = arrowBtn;
        
        /**
         setSwitch
         */
        UISwitch *setSwitch = [UISwitch new];
        setSwitch.onTintColor = CSColorFromRGB(0xFFEC00);
        //        setSwitch.backgroundColor = CSWhiteColor;
        setSwitch.clipsToBounds = YES;
        setSwitch.thumbTintColor = CSWhiteColor;
        setSwitch.hidden = YES;
        [self addSubview:setSwitch];
        self.setSwitch = setSwitch;
        
        /**
         箭头
         */
        UIView *sepView = [UIView new];
        sepView.backgroundColor = CSClearColor;
        [self addSubview:sepView];
        self.sepView = sepView;
        
        
        
        [self setConstraints];
    }
    
    return self;
}

-(void)setConstraints
{
    
    /**
     图标
     */
    [self.imgView mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.mas_equalTo(self);
        make.left.mas_equalTo(self).offset(20);
        make.width.height.mas_equalTo(20);
        
    }];
    
    /**
     主题
     */
    [self.titleLable mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.mas_equalTo(self);
        make.left.mas_equalTo(self.imgView.mas_right).offset(10);
        
    }];
    
    
    /**
     副主题
     */
    [self.subTitleLable mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.mas_equalTo(self);
        
    }];
    
    /**
     箭头
     */
    [self.arrowBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.mas_equalTo(self);
        make.left.mas_equalTo(self.subTitleLable.mas_right).offset(5);
        make.right.mas_equalTo(self).offset(-10);
    }];
    
    
    /**
     setSwitch
     */
    [self.setSwitch mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.mas_equalTo(self);
        make.right.mas_equalTo(self).offset(-10);
    }];
    
    
    
    /**
     sepView
     */
    [self.sepView mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(1);
        make.left.mas_equalTo(self.titleLable);
        make.right.mas_equalTo(self).offset(0);
        make.bottom.mas_equalTo(self);
    }];
}



@end
